//
//  UIImage+DBExtension.swift
//  DBCA
//
//  Created by mugua on 2024/6/30.
//

import Foundation
import UIKit

extension UIImage {
    
    public static func imageWithColor(color: UIColor) -> UIImage {
        let rect = CGRectMake(0, 0, 1, 1)
        UIGraphicsBeginImageContext(rect.size)
        let context = UIGraphicsGetCurrentContext()
        context?.setFillColor(color.cgColor)
        context?.fill(rect)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        guard image != nil else {
            return UIImage()
        }
        return image!
    }
}
